import pygame
from pygame.locals import Rect
from enum import Enum

class State(Enum):
    INVISIBLE = 0
    FAIL = 1
    SUCCESS = 2
    
class Result:
    sysfont = None
    def __init__(self, pos ):
        if(not Result.sysfont):
            Result.sysfont = pygame.font.SysFont('Sans', 144)
        self.message = None
        self.messageRect = None
        self.state = State.INVISIBLE.value
        self.rect = Rect((0, 0, 512, 256))
        self.rect.move_ip(pos)
    
    def render(self):
        from main import SURFACE
        if(self.state == State.INVISIBLE.value):
            return
        else:
            SURFACE.blit(self.message, self.messageRect)
            

    def enable(self, isSuccessful):
        if(isSuccessful):
            self.message = Result.sysfont.render("SUCCESS", True,(0, 0, 120))
            self.state = 2
        else:
            self.message = Result.sysfont.render("FAIL", True, (190, 0, 0))
            self.state = 1
            
        self.messageRect = self.message.get_rect()
        self.messageRect.center = self.rect.center

    def disable(self):
        self.state = 0
                    

    
